
import AdminPrivs from './admin_privs.json'
import AdminWmsPrivs from './admin_wms_privs.json'

import OmsPrivs from "./oms_privs.json";
import MmsPrivs from "./mms_privs.json";

import SrmPrivs from "./srm_privs.json";
import UmsPrivs from "./ums_privs.json";
import WmsPrivs from "./wms_privs.json";
import TmsPrivs from "./tms_privs.json";
import PmsPrivs from "./pms_privs.json";
import FmsPrivs from "./fms_privs.json";

__LONG_USER__.ifElse澳越 = !!__LONG_USER__.currentAgentName && __LONG_USER__.currentAgentName.includes('澳越')


let mod =
{
  module: "** 测试 **",
  iconCls: "el-icon-s-opportunity",
  children: [
    {
      "name": "更新日志",
      "path": "/page/base/update_log"
    },
    {
      "name": "标准分页模板",
      "path": "/page/_test/standard_page",

    },
    {
      "name": "自动化选择组件ex_select_auto",
      "path": "/page/_test/readme_ex_select_auto",
    },
    {
      "name": "高阶输入组件ex_super_input",
      "path": "/page/_test/readme_ex_super_input",
    },
    {
      "name": "高阶表单组件ex_super_form",
      "path": "/page/_test/readme_ex_super_form",
    },
    {
      "name": "高阶表格组件ex_super_table",
      "path": "/page/_test/readme_ex_super_table",
    },
    {
      "name": "通用组件模板",
      "path": "/page/_test/superInput_form_template"
    }
  ]
}

// const baseAllAfter = {
//   module: "label_static_resources_list",
//   iconCls: "el-icon-files",
//   "path": "/page/base/static_resources_list"
// }


let all = []
if (process.env.NODE_ENV === "development") {
  all = [mod]
}

let arr = []

if (__LONG_USER__.userRoleType !== 'ADMIN' || __LONG_USER__.roleScope !== 'DEFAULT') {
  if (!__LONG_USER__.ifElse澳越) {
    OmsPrivs[0].children = OmsPrivs[0].children.filter(item => item.name !== 'label_purchase')
  }
}


// 混合菜单模式
if (__LONG_USER__.isMix) {
  arr = [
    OmsPrivs, MmsPrivs, SrmPrivs, UmsPrivs, PmsPrivs, FmsPrivs,
    TmsPrivs, WmsPrivs
  ]
}
else {
  if (__LONG_USER__.roleSystem == 'OMS') {
    arr = [OmsPrivs, MmsPrivs, SrmPrivs, UmsPrivs, PmsPrivs, FmsPrivs]
  }
  else if (__LONG_USER__.roleSystem == 'WMS') {
    arr = [WmsPrivs]
  }
  else if (__LONG_USER__.roleSystem == 'TMS') {
    arr = [TmsPrivs]
  }

}

if (__LONG_USER__.isSuperAdmin()) {
  if (__LONG_USER__.roleSystem == 'OMS') {
    arr = [AdminPrivs, ...arr]
  } else if (__LONG_USER__.roleSystem == 'WMS') {
    arr = [AdminWmsPrivs, WmsPrivs]
  }

}
arr.forEach(model => {
  model.forEach(folder => {
    all = all.concat(folder.children,)
  })
})

// all = all.concat([baseAllAfter])

export default all
